<?xml version="1.0" encoding="UTF-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- IE 浏览作用 兼容模式打开页面。 chrome=1 开启 chrome 支持，适用多个核的浏览器。 -->
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta charset="UTF-8">
	<title>JEHC-Bpm业务平台..</title>
	<link rel="icon" type="image/ico" href="/deng/images/top/552cc62e6ad78_32.png" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="format-detection" content="telephone=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

	<link href="/deng/source/plugins/newAdmin/vendors/base/flaticon.css" rel="stylesheet" type="text/css" />
    <link href="/deng/source/plugins/newAdmin/bootstrap/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/icons.css" rel="stylesheet" type="text/css" />
    <link href="/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/style.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/deng/source/css/loginicon/iconfont.css" />
	<script src="/deng/source/css/loginicon/iconfont.js" type="text/javascript" charset="utf-8"></script>
	<link href="/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/icons.css" rel="stylesheet" type="text/css" />
	<!-- 基础插件样式开始 -->
	<link href="/deng/source/plugins/newAdmin/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
	<!-- 基础插件样式结束 -->
	<!-- 自定义主题样式开始 -->
	<link href="/deng/source/css/login.css" rel="stylesheet" type="text/css" />
	<!-- 自定义主题样式结束 -->
	<!-- 基础插件开始 -->
	<script src="/deng/source/plugins/newAdmin/vendors/base/jquery.min.js" type="text/javascript"></script>
	<script src="/deng/source/plugins/newAdmin/bootstrap/4.0.0/js/bootstrap.min.js" type="text/javascript"></script>
	<!-- 基础插件结束 -->
	<!-- 提示插件开始 -->
	<link href="/deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.css" rel="stylesheet" type="text/css" />
	<script src="/deng/source/plugins/newAdmin/bootstrap/bootstrap-toastr/toastr.min.js" type="text/javascript"></script>
	<script src="/deng/source/plugins/newAdmin/bootstrap/bootbox.js" type="text/javascript"></script>
	<!-- 提示插件结束 -->
	<!-- bootstrap验证框架开始 -->
	<link rel="stylesheet" type="text/css" href="/deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.css" />
	<script src="/deng/source/plugins/newAdmin/bootstrap/bootstrap-validate/bootstrapValidator.js" type="text/javascript"></script>
	<!-- bootstrap验证框架结束 -->
	<!-- 公共模块包含上传控件，共同JS封装 -->
	<script type="text/javascript" src="/deng/source/js/base.js"></script>
	<script type="text/javascript" src="/deng/source/js/boot.min.js"></script>
	<style>
		.modal.in .modal-dialog{-webkit-transform:translate(0,-50%);-ms-transform:translate(0,-50%);-o-transform:translate(0,-50%);transform:translate(0,-50%)}
		.modal-dialog{position:absolute;width:auto;margin:10px auto;left:0;right:0;}
		@media (min-width:400px) {
			.modal-dialog {
				width: 400px
			}

			.modal-body {
				min-height: 420px;
			}

			.input-icon > .form-control {
				height: 50px;
			}

			.form-control {
				border: 1px solid #f5f5f5;
				border-radius: 0px;
			}
			.titlee {
				width: 100%;
				margin: auto;
				padding-top: 18%;
				padding-left: 4%;
			}
			.input-icon>i {
				position: absolute;
				margin-top: 12px;
			}
			.bv-form .help-block {
				color: red;
			}
			.modal .modal-header {
				background: #32c5d2;
				height: 70px;
			}

			.modal-title {
				color: #ffffff;
				margin-top: 5px;
			}

			.modal-backdrop, .modal-backdrop.fade.in {
				background-color: #f5f5f5 !important;
			}

			.modal-backdrop.in {
				opacity: .5;
				filter: alpha(opacity=50);
			}

			.btn-primary {
				color: #fff;
				background-color: #32c5d2;
				border-color: #32c5d2;
			}

			.modal-footer {
				padding: 15px;
				text-align: right;
				border-top: 0px solid #e5e5e5;
			}

			.bv-form .help-block {
				color: red;
			}
			#loginBtn{
				width: 352px;
				height: 56px;
				background: #2194F7;
				color: #fff;
				font-size: 26px;
				border-radius: 5px!important;
			}
			.has-error .form-control{
				border-color: #fff;
			}
		}
	</style>
</head>
<body>
<div>
	<!-- 模态框（Modal） -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop=”static” aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content modal-lg">
				<div class="modal-header">
					<h4 class="modal-title" id="myModalLabel" >
						欢迎使用JEHC开源平台...
					</h4>
				</div>
				<div class="modal-body">
					<form id="loginForm" method="post">
						<div class="form-group">
							<label class="control-label"><font style="font-size:16px;font-family:楷体;color:#CFCFCF;">输入登录信息时，请注意周边环境</font></label>
							<div class="input-icon">
								<!--<label class="control-label">账号</label>-->
								<i class="flaticon-user-ok"></i>
								<input class="form-control" type="text" placeholder="请输入账号" name="account" id="account" />
							</div>
						</div>
						<div class="form-group">
							<div class="input-icon">
								<!--<label class="control-label">密码</label>-->
								<i class="flaticon-lock"></i>
								<input class="form-control placeholder-no-fix" type="password" placeholder="请输入密码" name="password" id="password"/>
							</div>
						</div>
						<div class="row">
							<div class="col-sm-6">
								<div class="form-group">
									<div class="input-icon">
										<i class="flaticon-logout" style="font-size: 28px;"></i>
										<input class="form-control placeholder-no-fix" type="text" placeholder="请输入验证码" name="validateCode" id="validateCode"/>
									</div>
								</div>
							</div>
							<div class="col-sm-3">
								<img id="safecode" width="180"/>
								<br><a href="javascript:clickYZM()">换一张</a><br><br>
							</div>
						</div>
						<div class="form-actions">
							<div class="checkbox">
								<input type="checkbox" name="readme" id="readme" value="1" />
								<label for="readme">
									记住我？
								</label>
							</div>
						</div>
						<div class="form-group">
							<input type="button" id="loginBtn" class="btn btn-primary" style="width: 370px;height:50px;" onclick="login()" value="登 录">
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<div style="text-align: center;margin: 0 auto;width: 100%;">
						<a target="_blank" href="http://beian.miit.gov.cn">苏ICP备18036217号-1</a>
					</div>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal -->
	</div>
</div>
</body>

<script type="text/javascript">
    clickYZM();
    function callFocus() {
        var account = $('#account').val();
        var password = $('#password').val();
        var validateCode = $('#validateCode').val();
        if(account == null || account == '') {
            return $('#account')[0].focus();
        }
        if(password == null || password == '') {
            return $('#password')[0].focus();
        }
        if(validateCode == null || validateCode == '') {
            return $('#validateCode')[0].focus();
        }
    }
    $(document).ready(function() {
        if(getnavigator()==7 || getnavigator()==8 || getnavigator()==9 || getnavigator() == 6 || getnavigator() == 0){
            document.write("平台支持IE10及以上浏览器或谷歌，火狐，360极速模式等浏览器");
            return;
        }
        $('#myModal').modal({backdrop: 'static', keyboard: false});
        if(getCookie('readme') == 'readme'){
            $("[name='readme']").attr("checked",'true');
            $('#userName').val(getCookie('XTUSERNAMECOOKIE'));
            $('#password').val(getCookie('XTUSERPASSWORDCOOKIE'));
        }
        $("#myModal").on('shown.bs.modal', function(e){
            var _this = e.target;
            var dl = $(_this).find('.modal-dialog')[0];
            var top = ($(_this).height() - $(dl).height())/2;
            top = top < 0 ? 0 : top;
            $(dl).animate({'margin-top':top+'px'},700);
        });
    });

    //刷新验证码
    function clickYZM() {
        if(getCookie("JEHC-SESSION-ID") != undefined && null != getCookie("JEHC-SESSION-ID") && "" != getCookie("JEHC-SESSION-ID")){
            document.getElementById('safecode').src = oauthModules+ "/verify?date="+new Date().getTime()+"&sessionId="+getCookie("JEHC-SESSION-ID");
		}else{
            $.ajax({
                url:oauthModules + '/JSessionId',
                type:'GET',
                // xhrFields:{withCredentials:true},
                contentType:"application/json;charset=utf-8",
                data:[],
                success: function(result) {
                    var obj = result;
                    setCookie("JEHC-SESSION-ID", obj.data, 60*24);
                    document.getElementById('safecode').src = oauthModules+ "/verify?date="+new Date().getTime()+"&sessionId="+obj.data;
                },
                error: function() {
                    window.parent.toastrBoot(4, "生成SessionID出现异常!");
                }
            })
		}
    }

    $('#loginForm').bootstrapValidator({
        message: '此值不是有效的',
        feedbackIcons: {},
        fields: {
            account: {
                validators: {
                    notEmpty: {
                        message: '用户账号不能为空'
                    },
                    stringLength: {
                        min: 1,
                        max: 30,
                        message: '用户账号字符长度不能超过30个'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: '密码不能为空'
                    },
                    stringLength: {
                        min: 1,
                        max: 20,
                        message: '密码字符长度不能超过20个'
                    }
                }
            },
            validateCode: {
                validators: {
                    notEmpty: {
                        message: '验证码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 6,
                        message: '验证码只能为6个字符'
                    }
                }
            }
        }
    });

    $(function() {
        document.onkeydown = function(e) {
            var ev = document.all ? window.event : e;
            if(ev.keyCode == 13) {
                login();
            }
        }
    });
    //提交登录form
    function login() {
        callFocus();
        var bootform = $('#loginForm');
        if(typeof(bootform) == "undefined" || null == bootform || '' == bootform) {
            window.parent.toastrBoot(4, "未能获取到form对象!");
            return;
        }
        //验证
        var boostrapValidator = bootform.data('bootstrapValidator');
        boostrapValidator.validate();
        //验证有效开启发送异步请求
        if(boostrapValidator.isValid()) {
            $.fn.serializeObject = function(){
                var o = {};
                var a = this.serializeArray();
                $.each(a, function() {
                    if (o[this.name] !== undefined) {
                        if (!o[this.name].push) {
                            o[this.name] = [o[this.name]];
                        }
                        o[this.name].push(this.value || '');
                    } else {
                        o[this.name] = this.value || '';
                    }
                });
                return o;
            };
            $("#loginBtn").attr("disabled", true);
            $("#loginBtn").val("正在登录中......");
            $.ajax({
                url:oauthModules + '/login',
                type:'POST', //PUT DELETE POST
                // xhrFields:{withCredentials:true},
                contentType:"application/json;charset=utf-8",
                data:JSON.stringify(bootform.serializeObject()),
                success: function(result) {
                    call(result);
                },
                error: function() {
                    clickYZM();
                    $("#loginBtn").val("登录");
                    $("#loginBtn").attr("disabled", false);
                }
            })
        } else {
            //window.parent.toastrBoot(4,"存在不合法的字段!");
        }
    }

    function call(result) {
        try {
            var obj = result;
            if(obj.success == false) {
                clickYZM();
                window.parent.toastrBoot(4, obj.message);
                $("#loginBtn").val("登录");
                $("#loginBtn").attr("disabled", false);
            } else {
                clearCookie('readme');
                clearCookie('XTUSERNAMECOOKIE');
                clearCookie('XTUSERPASSWORDCOOKIE');
                if($('#readme').is(':checked')) {
                    if(null == getCookie('readme') || '' == getCookie('readme')) {
                        setCookie('readme', 'readme', 240);
                        setCookie('XTUSERNAMECOOKIE', $('#account').val(), 240);
                        setCookie('XTUSERPASSWORDCOOKIE', $('#password').val(), 240);
                    }
                }
                setCookie("Token", obj.data, 60*24);
                // console.log("-------",obj.data);
                // console.log("-------",getCookie("Token"));
                $("#loginBtn").val("身份认证成功，开始进入平台......");
                window.parent.toastrBoot(3, "身份认证成功，开始进入平台......");
                window.location.href = basePath + "/index.html";
            }
        } catch(e) {
            $("#loginBtn").val("登录");
            $("#loginBtn").attr("disabled", false);
        }
    }

    document.onreadystatechange = pagecomplete;

    function pagecomplete() {
        if(document.readyState == "complete") {
            setTimeout(function() {
                callFocus();
            }, 500);
        }
    }
</script>

</html>